/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.atm.controller;

import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import org.atm.domain.Account;
import org.atm.domain.Client;
import org.atm.service.AccountService;
import org.atm.service.ClientService;

/**
 *
 * @author Rahul
 */
@ManagedBean(name = "accountBean")
public class AccountBean extends AbstractBean {

    private Account selectedAccount;
    @EJB
    private AccountService accountService;
    @EJB
    private ClientService clientService;

    public AccountBean() {
    }

    public List<Account> getAccounts() {
        String cardNumber = getAuthenticatedCardNumber();
        Client client = clientService.getByATMCardNumber(cardNumber);
        
        return client.getAccounts();
    }

    public Account getSelectedAccount() {
        return selectedAccount;
    }

    public void setSelectedAccount(Account selectedAccount) {
        this.selectedAccount = selectedAccount;
    }

    public String viewAccounts() {
        return "account_list";
    }
}
